"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Proxy = require("harmony-proxy");
function createProxy(state, previousState, multiplier) {
    return new Proxy(state, createHandler(previousState, multiplier));
}
exports.createProxy = createProxy;
function createHandler(previousState, multiplier) {
    return {
        get(state, property) {
            let currentValue = state[property];
            let previousValue = previousState[property];
            if (currentValue === undefined) {
                currentValue = previousValue;
            }
            if (previousValue === undefined) {
                previousValue = currentValue;
            }
            if (typeof (currentValue) === 'number' && typeof (previousValue) === 'number') {
                const result = currentValue + (previousValue - currentValue) * multiplier;
                return isNaN(result) ? null : result;
            }
            else if (currentValue === null) {
                return null;
            }
            else if (typeof (currentValue) === 'object') {
                return createProxy(currentValue, previousValue, multiplier);
            }
            else {
                return currentValue;
            }
        },
    };
}
